using System.Drawing;
using System.Reflection;
using System.Resources;

namespace ThirdLife.UI.WinForms
{
  public class ThirdLifeResources
  {
    private static ThirdLifeResources _singleton;
    private readonly ResourceManager _manager;

    private ThirdLifeResources()
    {
      // C#
      // Gets a reference to the same assembly that 
      // contains the type that is creating the ResourceManager.
      Assembly myAssembly = GetType().Assembly;

      // Creates the ResourceManager.
      _manager = new
        ResourceManager("ThirdLife.UI.WinForms.ThirdLife",
                        myAssembly);
    }

    public static ThirdLifeResources Instance
    {
      get
      {
        if (_singleton == null)
          _singleton = new ThirdLifeResources();
        return _singleton;
      }
    }

    public string GetText(string stringHandle)
    {
      return _manager.GetString(stringHandle);
    }

    public Image GetImage(string imageHandle)
    {
      return (Image)_manager.GetObject(imageHandle);
    }

    public Icon GetIcon(string iconHandle)
    {
      return (Icon)_manager.GetObject(iconHandle);
    }
  }
}